var http = require('http');
var url = require('url');
var util = require('util');
const diditaxi = require("./diditaxi");
 
http.createServer(function(req, res){
    res.writeHead(200, {'Content-Type': 'text/plain;charset=utf-8'});
 
    console.log(url.parse(req.url).path);
    console.log(req.headers);
    var params = url.parse(req.url, true).query;
    console.log(JSON.stringify(params));
	if(url.parse(req.url).path.startsWith('/diditaxi')){
        console.log("diditaxi");

        diditaxi.recharge(params.phone,params.code).then(function(data){
            console.log(data);
            res.write(JSON.stringify(data));
            res.end();
        });
    
    }


 
}).listen(3000);